const path = require('path');
const express = require('express');
const session = require('express-session');
const logger = require('morgan');

const port = 3000;
const app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'assets')));

/* - - - - 启用处理会话的中间件 - - - - - - - - - -  */
let options = {
    name: 'KFMID',
    secret: 'kaifamiao',
    resave: false,
    saveUninitialized: true,
    cookie: {
        secure: false,
        path: '/' 
    }
}

// 创建用于处理会话的中间件
let sessionMiddleware = session(options);
app.use(sessionMiddleware);
/* - - - - - - - - - - - - - - - - - - - - - - - -  */

app.get( '/' , (req,resp)=>{
    resp.redirect( '/index.html' );
  });

app.listen( port );